﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Net.Mime;
using System.IO;
using System.Data;
using System.Data.SqlClient;
//using System.Web.Mail;
using System.Net.Mail;
public partial class FranchiseOpportunity : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //ddlexp.Items.Clear();
        //ddlexp.Items.Add(string.Empty);
        //for (int i = 0; i <= 100; i++)
        //{
        //    ddlexp.Items.Add(i.ToString());
        //}
    }

    public void SendMailMethod()
    {
        string Info = "";
        string experience = "";
        Info = "<span style=\"font-size:12px;\"><br>" +
                "Dear <b> Admin</b>,<br><br>Please find the details of Enquiry As below:<br>" +
                "<div><table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" style=\"font-size: 13px; font-family: Arial, Helvetica, sans-serif;\" width=\"97%\">" +

        "<tr><td align=\"left\" class=\"form_table_header\" height=\"25\" valign=\"top\" width=\"34%\"><b style=\"color: rgb(15, 106, 172);\">A .Your Contact Details</b></td><td align=\"left\" valign=\"top\" width=\"66%\">&nbsp;</td></tr>" +
        "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">First Name:</td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">" + txtName.Text + "</td></tr>" +
        "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">Last Name:</td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">" + txtLastName.Text  + "</td></tr>" +
        "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">Email ID:</td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">" + txtEmailID.Text  + "</td></tr>" +
        "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">Mobile no:</td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">" + txtmobno.Text + "</td></tr>" +
        "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">Landline no:</td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">" + txtlandlineno.Text + "</td></tr>" +
        "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">Preferred time to call:</td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">" + txttimetocall .Text+ "</td></tr>" +
        "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">&nbsp;</td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">&nbsp;</td></tr>" +
        "<tr><td align=\"left\" class=\"form_table_header\" height=\"25\" valign=\"top\"><b style=\"color: rgb(15, 106, 172);\">B. Your Franchise Plans</b></td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">&nbsp;</td></tr>" +
        "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">Preferred Country:</td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\"></td></tr>" +Country.SelectedValue + 
        "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">Preferred City:</td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">" + txtPrefCity.Text  + "</td></tr>" +
        "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">&nbsp;</td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">&nbsp;</td></tr>" +
        "<tr><td align=\"left\" height=\"25\" valign=\"top\"><span class=\"form_table_header\"><b style=\"color: rgb(15, 106, 172);\">C. Your Profile</b></span></td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">&nbsp;</td></tr>" +
        "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\" class=\"style1\">current doing:</td><td align=\"left\" style=\"color: rgb(0, 0, 0);\" valign=\"top\" class=\"style1\">Ram</td></tr>" +
        "<tr><td align=\"left\" colspan=\"2\" valign=\"top\"><div id=\"divOwnBusiness\">" +
        "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr valign=\"top\"><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\" width=\"34%\">Short description:</td><td align=\"left\" class=\"text\" valign=\"top\" width=\"66%\">txtNatureOfCurrentBusiness.text </td></tr></table>" +
        "</div></td></tr>" +
        "<tr valign=\"top\"><td colspan=\"2\" height=\"17\" valign=\"top\"></td></tr>" +
        "<tr valign=\"top\"><td align=\"left\" class=\"text\" style=\"color: rgb(204, 51, 153);\" valign=\"top\">healing<span class=\"Apple-converted-space\">&nbsp;</span>industry:<br />:</td><td align=\"left\" style=\"padding: 0px;\" valign=\"top\">"
             + rdITOrEducationExperience.SelectedValue + "</td></tr>" +
        "<tr><td>Number Of Educational Experience</td><td></td></tr>" +//ddlNoOfITOrEducationExperiences.Value
       "<tr><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\"><span class=\"form_table_header\"><b style=\"color: rgb(15, 106, 172);\">D.Questions/ Comments:<br />&nbsp;</b></span></td><td align=\"left\" style=\"color: rgb(204, 51, 153);\" valign=\"top\"><span style=\"padding: 0px;\">txtAptechInformation.text</td></tr></table></div>";

        //SendEmailToAdmin("", "", "Enquiry Details", Info);
        EmailManager.SendMail("ram@host2unlimited.com", ConfigurationManager.AppSettings["AdminEmail"].ToString(), "Franchise Enquiry", experience, ConfigurationManager.AppSettings["SmtpServerName"].ToString());
       
    }

    public static void SendEmailToAdmin(string From_Address, string To_Address, string Subject, string Content)
    {
        try
        {
            if (To_Address.Trim().Length == 0) { To_Address = ConfigurationManager.AppSettings["ToEmailID"].ToString(); }
            MailMessage mail = new MailMessage();
            //mail.From = new MailAddress("host2unlimited@yahoo.com");
            mail.From = new MailAddress(ConfigurationManager.AppSettings["FromEmailID"].ToString());
            mail.CC.Add(new MailAddress(ConfigurationManager.AppSettings["FromEmailID"].ToString()));
            mail.Subject = Subject;
            string content = Content;
            SmtpClient client = new SmtpClient();
            //client.Credentials = new System.Net.NetworkCredential("host2unlimited@yahoo.com", "123456789");
            client.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["FromEmailID"].ToString(), ConfigurationManager.AppSettings["EmailPassword"].ToString());
            client.Port = 25;
            string p = HttpContext.Current.Request.UserHostAddress;
            client.Host = ConfigurationManager.AppSettings["EmailHost"].ToString();//"smtp.mail.yahoo.com";//ConfigurationManager.AppSettings["EmailHost"].ToString();
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            AlternateView av1 = AlternateView.CreateAlternateViewFromString(content, null, MediaTypeNames.Text.Html);

            LinkedResource logo = new LinkedResource(HttpContext.Current.Server.MapPath("~/Images/logo1 (1).jpg"));

            logo.ContentId = "companylogo";
            logo.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
            av1.LinkedResources.Add(logo);

            mail.AlternateViews.Add(av1);
            mail.IsBodyHtml = true;
            mail.To.Add(To_Address);
            client.Send(mail);
        }
        catch (Exception exp)
        {
            throw exp;
        }
    }

   
    protected void submitButton_Click(object sender, ImageClickEventArgs e)
    {
        //SendMailMethod();
    }
}
